Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: inventory quantity resets to 0 when any variant or option quantity is undefined #5134

Merged
merged 6 commits into from
Apr 17, 2019

Conversation

kieckhafer
Copy link
Member

@kieckhafer kieckhafer commented Apr 17, 2019

Impact: major
Type: bugfix

Issue 1

When auto-updating variant quantites, based off a variants options quantities, if any of the children have an undefined quantity, the count gets reset to 0, causing an error and showing all inventory as 0.

It's caused by not adding parens around the || clause of the inventory check. For example, evaluate
50 + undefined || 0 vs 50 + (undefined || 0).

Solution

Add parens where necessary.


Issue 2

When querying for reserved products, we check every order in a certain status. We need to filter this better to create less of a drain on memory.

Solution

Add "shipping.items.variantId": variant._id filter to Orders query to only find orders with the variant we are querying.


Issue 3

Collection indexes were incorrect.

Solution

Fix indexes, and add migration to remove old indexes

@kieckhafer kieckhafer changed the base branch from master to develop April 17, 2019 20:50
@kieckhafer kieckhafer changed the title Fix kieckhafer inventory update quantity reset issue fix: inventory update quantity reset issue Apr 17, 2019
@kieckhafer kieckhafer changed the title fix: inventory update quantity reset issue fix: inventory quantity resets to 0 when any variant or option quantity is undefined Apr 17, 2019
@kieckhafer kieckhafer changed the title fix: inventory quantity resets to 0 when any variant or option quantity is undefined [WIP] fix: inventory quantity resets to 0 when any variant or option quantity is undefined Apr 17, 2019
@focusaurus
Copy link
Contributor

@kieckhafer could you please add a test case for the fix for issue 1 with the reduce syntax mistake? Should be pretty straightforward to reproduce in tests against the unfixed code and then confirm the fix is correct.

…entoryUpdateQuantityResetIssue

# Conflicts:
#	imports/plugins/core/orders/server/no-meteor/startup.js
@kieckhafer kieckhafer changed the title [WIP] fix: inventory quantity resets to 0 when any variant or option quantity is undefined fix: inventory quantity resets to 0 when any variant or option quantity is undefined Apr 17, 2019
Copy link
Contributor

@aldeed aldeed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and verified the fix

@aldeed aldeed merged commit 6b41438 into develop Apr 17, 2019
@aldeed aldeed deleted the fix-kieckhafer-inventoryUpdateQuantityResetIssue branch April 17, 2019 23:31
@jeffcorpuz jeffcorpuz mentioned this pull request Jul 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants